-
Notifications
You must be signed in to change notification settings - Fork 267
Check GitHub authentication before branch resolution in ParseGitHubUrl #6478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: vhvb1989 <24213737+vhvb1989@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue where azd ai agent init fails with a misleading error message about invalid branch names when GitHub authentication is missing or expired. The fix ensures users are prompted to authenticate before branch resolution attempts.
Key Changes
- Added
ensureGitHubAuthenticated()helper function to check and trigger GitHub authentication - Integrated authentication check into
ParseGitHubUrl()before branch API calls for raw/blob/tree URLs - Updated all existing tests to mock authentication status responses
- Added comprehensive test for unauthenticated scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cli/azd/pkg/templates/gh_source.go | Added ensureGitHubAuthenticated() function and integrated auth checks before branch resolution in ParseGitHubUrl() |
| cli/azd/pkg/templates/gh_source_test.go | Updated all tests to mock gh auth status, added new test Test_ParseGitHubUrl_NotAuthenticated to verify login flow |
|
Fix looks good on my end:
@copilot can you fix the golint error? |
Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
... Fixed in commit 2a62ff2. The struct fields in |
|
/check-enforcer evaluate |
weikanglim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM

Plan: Fix ParseGitHubUrl to check authentication before branch resolution ✅
Summary
This fix ensures that
ParseGitHubUrlchecks for GitHub authentication before attempting to resolve branch names via API calls. This provides users with a clear login prompt instead of cryptic error messages when they're not authenticated or have bad/expired credentials.Latest Change
Fixed struct field alignment in
Test_ParseGitHubUrl_NotAuthenticatedto pass gofmt checks. TheStdoutandStderrfields now align properly withExitCode.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.